23 #define D(x) cout << #x " is " << x << endl
25 const long double rho
= 6371.01;//km
26 const long double pi
= 2*acos(0.0);
30 long double dot(const Vector
&t
) const {
31 return x
*t
.x
+ y
*t
.y
+ z
*t
.z
;
33 long double mag() const{
34 return sqrt(x
*x
+ y
*y
+ z
*z
);
38 ostream
& operator << (ostream
&out
, Vector
&v
){
39 out
<< "<" << v
.x
<< ", " << v
.y
<< ", " << v
.z
<< ">";
43 long double phi
, theta
;
44 Vector
toVector() const{
46 v
.x
= sin(phi
)*cos(theta
);
47 v
.y
= sin(phi
)*sin(theta
);
53 istream
& operator >> (istream
&in
, point
&p
){
54 long double a
, b
, c
, d
, e
, f
;
56 in
>> a
>> b
>> c
>> X
>> d
>> e
>> f
>> Y
;
58 long double latitude
, longitude
;
59 latitude
= (a
+ b
/60.0 + c
/3600.0);
60 longitude
= (d
+ e
/60.0 + f
/3600.0);
62 p
.phi
= 90 + latitude
* (X
== 'N' ? -1.0 : 1.0);
63 p
.theta
= longitude
* (Y
== 'E' ? -1.0 : 1.0);
70 p
.phi
*= pi
/180.0, p
.theta
*= pi
/180.0; //"radianize"
75 long double dist(point
&a
, point
&b
){
76 Vector va
= a
.toVector(), vb
= b
.toVector();
79 cout << "Point A as a vector = " << va << endl;
80 cout << "Point B as a vector = " << vb << endl;
83 cout << "|A| = " << va.mag() << endl;
84 cout << "|B| = " << vb.mag() << endl;
87 long double angle
= acos(va
.dot(vb
));
93 for (scanf("%d", &n
); n
--; ){
96 printf("%.2llf\n", dist(a
, b
));